package com.admin.control.web;

import com.admin.service.SysPersonService;
import com.admin.service.vo.SysPerson;
import lombok.Data;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.HashMap;
import java.util.Map;
import java.util.Optional;

@Data
@RestController("mvcPermission")
@RequestMapping("mvc/permission")
public class PermissionController {

    @Autowired
    private SysPersonService sysPersonService;

    @GetMapping(value = "hello")
    public Map<String, String> hello() {
        Map<String, String> result = new HashMap<>();
        result.put("jack", "209007");
        return result;
    }

    @PostMapping(value = "createPerson")
    public SysPerson createPerson(@RequestBody SysPerson sysPerson) {
        Optional.ofNullable(sysPerson).ifPresent(cur -> {
            cur.toString();
            sysPersonService.createSysPerson(sysPerson);
        });
        return sysPerson;
    }



}
